import express, { Express, Request, Response } from "express"; //ts版的express
import userController from "./controller/userController";
import blogController from "./controller/blogController";
import blogtypeController from "./controller/blogtypeController";
import bannerController from "./controller/bannerController";
import blogUserController from "./controller/blogUserController";
import leaveController from "./controller/leaveController";
import commentController from "./controller/commentController";
// import middle from "./middleArea";
let app: Express = express(); //产生express对象
// app.get("/", function (req: Request, res: Response) {
//   //get请求启动服务器
//   res.send("hello nodejssd lkh");
// });
app.use("/static", express.static(__dirname + "/static"));
const bodyParser = require("body-parser");
// post数据最大是50mb
app.use(bodyParser.json({ limit: "50mb" }));
//设置文件上传
const multer = require("multer");
app.use(multer({ dest: "/tmp" }).array("file"));
//运行控制器
// middle(app);
commentController(app);
blogUserController(app);
blogtypeController(app);
bannerController(app);
userController(app);
leaveController(app);
blogController(app, __dirname);
app.listen(8080, function () {
  //绑定端口启动服务
  console.log("serve start");
});
